/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2023 —12 —06
 * Time: 14:17
 */
class Animal{
    public String name;
    public int age;

    public Animal (String name, int age){
        this.name = name;
        this.age = age;
    }

    public void eat(){
        System.out.println(this.name + "正在吃饭");
    }

        }



class Dog extends Animal{
    public Dog(String name , int age){
        super(name,age);
    }

    public void bark(){
        System.out.println(this.name +"汪汪叫");
    }
    @Override
    public void eat(){
        System.out.println(this.name + " 正在吃狗粮");
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    //@Override 用法自己理解  用来判断子类中构造方法的名字，在父类中有相同的吗？
    // 如果这个方法名在父类中存在，则不会报错，如果不存在，就会报错，但是编译程序能够通过，因为编译器会认为这是你在子类中新构造的一种方法
}

class Cat extends Animal{
    public Cat(String name , int age){
        super(name,age);
    }

    public void miaomiao(){
        System.out.println(this.name + "咪咪叫");
    }

    @Override
    public void eat() {
        System.out.println(this.name + "正在吃猫粮");

    }
}

public class Test {
    public static void eatFun(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
        Animal animal = new Dog("圆圆", 19);

        /*
        Dog dog = new Dog ("圆圆",19);
        System.out.println(dog);
*/
    }
}
